#include "common.h"
VOID DriverManager()
{
  MESSAGE message;
  SIGNAL  signal;
  /*
              Init the dirvers first ,
   then send the activate signal to the Init process
  */

  /*--------------------------FSDriver-------------------------------*/
  InitKernelPCB(FSDRIVER,(PVOID)GetPhysicalAddress(FSDriver),(0x200000-0x4000*FSDRIVER),10,"FSDriver",NULL,NULL);
  ActivateProcess(&kernelprocess[FSDRIVER]);
  message.destination=FSDRIVER;
  message.type=FSDRIVER_WHOIAM;
  SendMessage(&message);
  /*--------------------------KeyboardDriver-------------------------*/
  InitKernelPCB(KEYBOARDDRIVER,(PVOID)GetPhysicalAddress(KeyboardDriver),(0x200000-0x4000*KEYBOARDDRIVER),10,"KeyboardDriver",NULL,NULL);
  ActivateProcess(&kernelprocess[KEYBOARDDRIVER]);
  message.destination=KEYBOARDDRIVER;
  message.type=KEYBOARDDRIVER_WHOIAM;
  SendMessage(&message);
  /*----------Notify the ServerManager to create drivers-------------*/
  signal.dt=SERVERMANAGER;
  signal.signal=SIGNAL_ANY;
  signal.returnvalue=0;
  NotifyWaited(&signal);
/*-------------------------------------------------------------------------------------------------------------------*/
   while(1)
   {
    if(ReceiveMessage(&message)!=ARTIST_ERROR_OK)continue;
     switch(message.type)
     {
       case DRIVERMANAGER_WHOIAM:
       {
          Print("DriverManager begin...\n");
  //       message.destination=INIT;
    //     message.type=INIT_MMSERVER;
     //   SendMessage(&message);

          break;
       }
       
       case DRIVERMANAGER_FSDRIVER:
       {

         InitKernelPCB(FSDRIVER,(PVOID)GetPhysicalAddress(FSDriver),(0x200000-0x4000*FSDRIVER),10,"FSDriver",NULL,NULL);
         ActivateProcess(&kernelprocess[FSDRIVER]);
         message.destination=FSDRIVER;
         message.type=FSDRIVER_WHOIAM;
         SendMessage(&message);
         break;
       }
       case DRIVERMANAGER_KEYBOARDDRIVER:
       {
         InitKernelPCB(KEYBOARDDRIVER,(PVOID)GetPhysicalAddress(KeyboardDriver),(0x200000-0x4000*KEYBOARDDRIVER),10,"KeyboardDriver",NULL,NULL);
         ActivateProcess(&kernelprocess[KEYBOARDDRIVER]);
         message.destination=KEYBOARDDRIVER;
         message.type=KEYBOARDDRIVER_WHOIAM;
         SendMessage(&message);
         break;
       }
     }
   }
}
